#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int count_setbit(unsigned numric){
    int c = 0;
    while (numric) {
        if (numric & 1) ++c;
        numric >>= 1;
    }

    return c;
}


int int_bin_len(void){
    /*return count_setbit(~0u); */
    return count_setbit(UINT_MAX);
}

void print_bin(int digital){
    int len = int_bin_len();

    printf("digital: %d\n", digital);

    for (int i =len-1; i>=0; i--) {
        if (!((i+1) % 8)) putchar(' ');

        printf("%c", (digital & (1<<i))? '1': '0');
    }

    putchar('\n');
    putchar('\n');
}

int main(void){
    print_bin(0);
    print_bin(-1);

    print_bin(9);
    print_bin(15);

    print_bin(14);
    print_bin(35);
    printf("14 & 35 = ");
    print_bin(14 & 35);

    printf("14 | 35 = ");
    print_bin(14 | 35);

    return 0;

}
